<template>
  <CommonModule
    showActionCol
    :showPagination="false"
    :columns="columns"
    :fetchList="fetchList"
    :actionRender="renderTableBtnAction"
  />
</template>
<script>
import CommonModule from './CommonModule';
import { IMAGE_TEXT_INFO_COLUMNS } from './constants';
import { getTableAction } from '@/utils/getBtnsRender';
import { handleOpenNewPage } from '@/utils/bizUtils';
import { getPrepareSpuListByRecordNoService } from '@/api/commodity/commodityAccessManage/commodityAdd';
export default {
  components: {
    CommonModule
  },
  data () {
    return {
      columns: IMAGE_TEXT_INFO_COLUMNS,
    }
  },
  methods: {
    // 获取表格数据
    async fetchList (params, loadingFn) {
      const data = _.pick(params, ['recordNo'])
      const res = await getPrepareSpuListByRecordNoService(data, loadingFn)
      return {
        results: res?.retData ?? []
      }
    },
    // 渲染表格操作栏按钮
    renderTableBtnAction (h, { row }) {
      const actionList = [{ label: '查看', method: this.handleToView }]
      return getTableAction({ h, row, actionList })
    },
    // 查看
    handleToView (row) {
      handleOpenNewPage(this, {
        name: 'accessSpuRecordImageTextView',
        query: {
          spuNo: row.spuNo,
          recordNo: this.$route?.query?.recordNo
        }
      })
    }
  }
}
</script>
